# -*- coding: UTF-8 -*-
from fastapi import FastAPI, Path, Query

app = FastAPI()


@app.get("/items/{item_id}")
async def read_items(
        # ge和le都会在api文档中进行提示
        item_id: int = Path(..., title="The ID of the item to get", ge=50, le=100),
        q: str = Query(None, alias="item-query"),
        # gt和lt不会在api文档中进行提示
        size: float = Query(..., gt=0, lt=10.5)
):
    results = {"item_id": item_id}
    if q:
        results.update({"q": q})
    if size:
        results.update({'size': size})
    return results


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, host="127.0.0.1", port=8000)
